#ifndef slak_tetris_tetrad_h
#define slak_tetris_tetrad_h

#include <cstddef>

namespace slak {

	namespace tetris {

		enum shape {
			RANDOM_SHAPE = -1,
			O = 0,
			I,
			L,
			J,
			Z,
			S,
			T,

			N_SHAPES,
		};

		enum square_state {
			EMPTY = 0,
			RED,
			BLACK,
			MAGENTA,
			BLUE,
			GREEN,
			BROWN,
			CYAN,

			N_STATES,
		};

		struct Tetrad {
			int width, height;
			int cx,cy;
			square_state * mask;

			Tetrad();
			Tetrad(int w, int h, int cx=-1, int cy=-1);
			Tetrad(const Tetrad& other);
			Tetrad& operator=(const Tetrad& other);
			virtual ~Tetrad();
			virtual void clear();
			virtual square_state& sq(int i, int j);
			virtual square_state  sq(int i, int j) const;
			Tetrad rotate() const;
			bool collides(int x, int y,const Tetrad& other);
			bool operator==(const Tetrad& other) const;
			bool operator!=(const Tetrad& other) const;
			bool empty() const { return mask==NULL; }
			bool lineComplete(int j) const;
			void delLine(int j);
			int delAllComplete();
			int countComplete();

			static Tetrad make(shape s = RANDOM_SHAPE, 
					   int n_rot = -1);
		};

	}
}

#endif
